import { MES_XHY_ApiHost } from '@/utils/Interceptors'

// 用户信息接口
export interface User {
  id: number
  account: string
  name: string
  role: string
  isActive: boolean
  organizationStructure: string
  remark: string
  avatar: string
  gender: string
}

// 用户搜索参数接口
export interface UserSearchParams {
  account?: string
  name?: string
  role?: string
  isActive?: boolean
}

// 获取用户列表
export const getUsers = async (searchParams?: UserSearchParams) => {
  const params = new URLSearchParams()
  
  if (searchParams?.account) {
    params.append('account', searchParams.account)
  }
  if (searchParams?.name) {
    params.append('name', searchParams.name)
  }
  if (searchParams?.role) {
    params.append('role', searchParams.role)
  }
  if (searchParams?.isActive !== undefined) {
    params.append('isActive', searchParams.isActive.toString())
  }
  
  const queryString = params.toString()
  const url = queryString ? `/api/Login/getAllUsers?${queryString}` : '/api/Login/getAllUsers'
  
  return await MES_XHY_ApiHost.get(url)
}

// 获取所有用户（简化版本）
export const getAllUsers = async () => {
  return await MES_XHY_ApiHost.get('/api/Login/getAllUsers')
}
